package com.jwdf.uda.ui.fragment.question.index;
import android.annotation.SuppressLint;
import android.databinding.DataBindingUtil;
import android.view.View;

import com.jwdf.uda.R;
import com.jwdf.uda.bean.PbBean;
import com.jwdf.uda.databinding.ViewNetErrorBinding;
import com.jwdf.uda.event.QuizNetErrorEvent;
import com.jwdf.uda.ui.activity.NewProblemsActivity;
/**
 * Created by fatsfan on 2016/9/8.
 */
@SuppressLint("ValidFragment")
public class QuizMineFragment extends QuizIndexFragment {

    View.OnClickListener onClick = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(v.getId() == R.id.vNewProblem) {
                startActivityFromFragment(NewProblemsActivity.class);
            }
        }
    };

    public QuizMineFragment() {
        restType = PbBean.PbSignBaseQuestionType.QUESTION_INDEX_MINE;
        setTitle("我的");
    }
    @Override
    protected void initViews() {
        super.initViews();
        layEmpty = mDataBinding.layEmptyMine;
        mDataBinding.vNewProblem.setOnClickListener(onClick);
    }

    public void onEventMainThread(QuizNetErrorEvent event) {
        ViewNetErrorBinding errorBinding = DataBindingUtil.bind(mErrorView);
        errorBinding.failedLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                requestData(true);
            }
        });
        if (errorBinding.getRoot().getParent() == null) {
            mDataBinding.quizContainer.addView(errorBinding.getRoot());
        }
    }

}
